﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace WhsFacebook.Net.Web.Facebook.Handlers
{
    public abstract class SafeHttpHandler : IHttpHandler
    {
        protected readonly log4net.ILog _log;

        public virtual bool IsReusable
        {
            get { return true; }
        }

        public void ProcessRequest(HttpContext context)
        {
            if (context == null)
                throw new ArgumentNullException("context");

            try
            {
                ProcessRequestSafe(context);
            }
            catch (Exception x)
            {
                _log.Error("HTTP handler request failed", x);
                
                throw;
            }
        }

        protected abstract void ProcessRequestSafe(HttpContext context);

        protected SafeHttpHandler()
        {
            _log = log4net.LogManager.GetLogger(GetType());
        }

    }
}